package com.tanhua.dubbo.api;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.domain.BlackList;
import com.tanhua.domain.UserInfo;
import com.tanhua.dubbo.mapper.BlackListMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;


@DubboService
public class BlackListApiImpl implements BlackListApi{

    @Autowired
    private BlackListMapper blackListMapper;

    @Override
    public void delectBlack(Long userId, Long blackId) {
        LambdaQueryWrapper<BlackList> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(BlackList::getUserId,userId);
        queryWrapper.eq(BlackList::getBlackUserId,blackId);
        blackListMapper.delete(queryWrapper);
    }

    @Override
    public IPage<UserInfo> findById(Long userId, Integer page, Integer size) {
        //根据userid查询黑名单列表
        IPage<UserInfo> ipage = new Page<>(page,size);

        return blackListMapper.findLst(userId,ipage);
    }
}
